var app = getApp();
const pathUrl = app.globalData.pathUrl;
Page({
  data: {
    searchInput: '',
    searchValue: '',
    deleteBtnHide: true,
    loading: false, //"上拉加载"的变量，默认false，隐藏  
    loadingComplete: false,  //“没有数据”的变量，默认false，隐藏 
    index: 0,
    pathUrl: pathUrl,
    openId: '',
    list: [],
    posxjtype:' '
  },
    onLoad: function (e) {
        var openId = wx.getStorageSync('openId');
        this.setData({
            openId: openId,
            posxjtype: e.posxjtype
        });
        var that = this;
        wx.setNavigationBarTitle({
            title: that.data.posxjtype,
        })
        this.fxjProMainController();
    },
  //点击搜索按钮
  search: function (e) {
    this.setData({
      searchValue: e.detail.value
    })
    // wx.nextTick(() => {
    //     this.setData({ 
    //         searchValue: ''
    //     })
    // })
    this.ssjg();
  },
  //删除输入框value
  deleteBtn: function () {
    this.setData({
      searchValue: '',
      deleteBtnHide: true
    })
  },
  //监听input value
  searchInputValue: function (e) {
    this.setData({
      searchValue: e.detail.value
    })
    if (e.detail.value != '') {
      this.setData({
        deleteBtnHide: false
      })
    } else {
      this.setData({
        deleteBtnHide: true
      })
    }
  },
  ssjg: function () {
    var that = this;
    that.setData({
      loadingComplete: false, //把“没有数据”设为true，显示  
      loading: false,//把"上拉加载"的变量设为false，隐藏  
      pageNumber: 0,
      list: []
    });
    this.fxjProMainController();
  },


    goStep: function (e) {
        var proNo = e.currentTarget.dataset.prono;
        var proName = e.currentTarget.dataset.proname;
        var bpmStatus = e.currentTarget.dataset.bpmstatus;
        wx.navigateTo({
          url: "/pages/applyMortgage/applyMortgage?proNo=" + proNo + '&proName=' + proName + '&bpmStatus=' + bpmStatus  
          // url: "/pages/posXjOne/posXjOne?proNo=" + proNo + '&proName=' + proName
        })
    },
  //产品详情
  fxjProMainController: function () {
    var that = this;
    wx.request({
      url: pathUrl + '/rest/posXjtaskController/list/' + that.data.openId,
      data: {
        posName: that.data.searchValue,

        posXjType: that.data.posxjtype,
        pageNumber: 1,
        pageSize: 10
      },
      success: function (res) {
        if (res.data.ok || res.data.data) {
          that.setData({
            list: res.data.data
          })
        } else {
          wx.showModal({
            title: '提示',
            content: '获取数据失败',
            confirmColor: '#7aa6d1',
            showCancel: false
          })
        }
      }
    })
  },
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.fxjProMainController();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})